<?php
/**
 * User: Mark Johnson
 * Date: Sep 28, 2010
 * Time: 6:48:11 PM
 * 
 * All requests are redirected here using the configurations in the .htaccess file.
 * 
 * Redirecting all requests to this file allows the system to properly load necessary
 * configuration data, system variables, database connections and functions, 
 * rendering functions, form creation functions, etc. 
 * 
 * The only page request that does not get redirected here is to install.php because if the
 * system has not been installed yet, it cannot load. 
 * 
 */

define('RUN_TESTS', FALSE);
//define('RUN_TESTS', TRUE);

define('DEBUG', FALSE);

$q = $_GET['q'];

/**
 * main()
 * 
 * This function builds the "system" that supports all page rendering and form creation in the entire site 
 * 
 * @param string $q
 * 		the URI as shown in a web browser
 * 
 * @return
 * 		an array of variables consisting that are useful for the rest of the functions in the system
 */
function main($q = '')
{
	if (defined('DEBUG') && DEBUG === TRUE)
	{
		include_once('./krumo/class.krumo.php');
	}
	
	// the initialization functions of the system
	require_once ('./includes/initialize.inc');
	return initialize(INITIALIZE_FULL);
}

$vars = main($q);

// This function call "loads" the desired content 
// $load is the a setup function for the file that contains the desired content 
call_user_func_array($load, array(&$vars));

// prints the output for the page
print(render('page', $vars));
